/**
  @(#)$Id: AL_Functional.h 69 2013-10-08 03:03:33Z xiaoting $
  @brief	Function objects
  Function objects are objects specifically designed to be used with a syntax similar to that of functions. In C++, this is 

  achieved by defining member function operator() in their typename, like for example:

	 struct myclass {
	 int operator()(int a) {return a;}
	 } myobject;
	 int x = myobject (0);           // function-like syntax with object myobject 
	
  They are especially useful as predicates or comparison functions to be used with standard algorithms.
  The standard library provides standard definitions for several function objects and some ways to modify and adapt their behavior 
  in header <functional>:

  @Author $Author: xiaoting $
  @Date $Date: 2013-10-08 11:03:33 +0800 (周二, 08 十月 2013) $
  @Revision $Revision: 69 $
  @URL $URL: https://svn.code.sf.net/p/xiaoting/game/trunk/MyProject/AL_DataStructure/groupinc/AL_Functional.h $
  @Header $Header: https://svn.code.sf.net/p/xiaoting/game/trunk/MyProject/AL_DataStructure/groupinc/AL_Functional.h 69 2013-10-08 03:03:33Z xiaoting $
 */

#ifndef CXX_AL_FUNCTIUONAL_H
#define CXX_AL_FUNCTIUONAL_H

// TEMPLATE STRUCT al_binary_function
template<typename _Arg1,
typename _Arg2,
typename _Result>
struct al_binary_function
{	// base typename for binary functions
	typedef _Arg1 first_argument_type;
	typedef _Arg2 second_argument_type;
	typedef _Result result_type;
};

// TEMPLATE STRUCT al_equal_to
template<typename _Ty>
struct al_equal_to
	: public al_binary_function<_Ty, _Ty, BOOL>
{	// functor for operator==
	BOOL operator()(const _Ty& _Left, const _Ty& _Right) const
	{	// apply operator== to operands
		return (_Left == _Right);
	}
};

// TEMPLATE STRUCT al_not_equal_to
template<typename _Ty>
struct al_not_equal_to
	: public al_binary_function<_Ty, _Ty, BOOL>
{	// functor for operator!=
	BOOL operator()(const _Ty& _Left, const _Ty& _Right) const
	{	// apply operator!= to operands
		return (_Left != _Right);
	}
};

// TEMPLATE STRUCT al_greater
template<typename _Ty>
struct al_greater
	: public al_binary_function<_Ty, _Ty, BOOL>
{	// functor for operator>
	BOOL operator()(const _Ty& _Left, const _Ty& _Right) const
	{	// apply operator> to operands
		return (_Left > _Right);
	}
};

// TEMPLATE STRUCT al_less
template<typename _Ty>
struct al_less
	: public al_binary_function<_Ty, _Ty, BOOL>
{	// functor for operator<
	BOOL operator()(const _Ty& _Left, const _Ty& _Right) const
	{	// apply operator< to operands
		return (_Left < _Right);
	}
};

// TEMPLATE STRUCT al_greater_equal
template<typename _Ty>
struct al_greater_equal
	: public al_binary_function<_Ty, _Ty, BOOL>
{	// functor for operator>=
	BOOL operator()(const _Ty& _Left, const _Ty& _Right) const
	{	// apply operator>= to operands
		return (_Left >= _Right);
	}
};

// TEMPLATE STRUCT al_less_equal
template<typename _Ty>
struct al_less_equal
	: public al_binary_function<_Ty, _Ty, BOOL>
{	// functor for operator<=
	BOOL operator()(const _Ty& _Left, const _Ty& _Right) const
	{	// apply operator<= to operands
		return (_Left <= _Right);
	}
};

#endif // CXX_AL_FUNCTIUONAL_H
/* EOF */
